import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: 'id',
    dataIndex: 'id',
    defaultHidden: true,
    align: 'center',
    width: 200,
  },
  {
    title: '公告标题',
    dataIndex: 'titile',

    align: 'center',
    width: 200,
  },
  {
    title: '公告内容',
    dataIndex: 'content',

    align: 'center',
    width: 200,
  },
  {
    title: '摘要',
    dataIndex: 'summary',

    align: 'center',
    width: 200,
  },
  {
    title: '公告类型',
    dataIndex: 'type',

    customRender: ({ record }) => {
      const options = [
        {
          label: '系统公告',
          value: '系统公告',
        },
        {
          label: '其他公告',
          value: '其他公告',
        },
      ];
      return options.find((op) => op.value === record.type)?.label || '暂无';
    },
    align: 'center',
    width: 200,
  },
  {
    title: '创建人',
    dataIndex: 'createdByName',

    align: 'center',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'titile',
    label: '公告标题',
    component: 'Input',
    componentProps: {
      placeholder: '请输入公告标题',
    },
    colProps: { span: 6 },
  },
  {
    field: 'type',
    label: '公告类型',
    component: 'Select',
    componentProps: {
      placeholder: '请选择公告类型',
      options: [
        {
          label: '系统公告',
          value: '系统公告',
        },
        {
          label: '其他公告',
          value: '其他公告',
        },
      ],
    },
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'id',
    component: 'Input',
    show: false,
    componentProps: {
      disabled: false,
      placeholder: '请输入id',
    },
    colProps: { span: 12 },
  },
  {
    field: 'type',
    label: '公告类型',
    component: 'Select',
    show: true,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请选择公告类型',
      options: [
        {
          label: '系统公告',
          value: '系统公告',
        },
        {
          label: '其他公告',
          value: '其他公告',
        },
      ],
    },
    colProps: { span: 18 },
  },
  {
    field: 'titile',
    label: '公告标题',
    component: 'Input',
    show: true,
    required: true,
    componentProps: {
      disabled: false,
      placeholder: '请输入公告标题',
    },
    colProps: { span: 18 },
  },
  {
    field: 'content',
    label: '公告内容',
    component: 'InputTextArea',
    show: true,
    required: true,

    componentProps: {
      disabled: false,
      placeholder: '请输入公告内容',
    },
    colProps: { span: 18 },
  },
  {
    field: 'summary',
    label: '摘要',
    component: 'Input',
    show: true,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入摘要',
    },
    colProps: { span: 18 },
  },
  {
    field: 'dateCreated',
    label: '创建时间',
    component: 'Input',
    show: false,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入创建时间',
    },
    colProps: { span: 12 },
  },

  {
    field: 'dateModified',
    label: '修改时间',
    component: 'Input',
    show: false,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入修改时间',
    },
    colProps: { span: 12 },
  },
  {
    field: 'createdBy',
    label: '创建人id',
    component: 'Input',
    show: false,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入创建人id',
    },
    colProps: { span: 12 },
  },
  {
    field: 'createdByName',
    label: '创建人',
    component: 'Input',
    show: false,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入创建人',
    },
    colProps: { span: 12 },
  },
  {
    field: 'modifiedBy',
    label: '修改人Id',
    component: 'Input',
    show: false,
    required: false,

    componentProps: {
      disabled: false,
      placeholder: '请输入修改人Id',
    },
    colProps: { span: 12 },
  },
];
